package com.yswl.pri.home.av;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.tencent.bugly.beta.ui.BaseDialogFrag;
import com.yswl.pri.R;
import com.yswl.pri.picture.PictureDialog;
import com.yswl.pri.picture.entry.ImageLoftBean;

import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import yswl.com.klibrary.base.MFragment;
import yswl.com.klibrary.http.CallBack.HttpCallback;
import yswl.com.klibrary.http.HttpClientProxy;
import yswl.com.klibrary.util.L;
import yswl.com.klibrary.util.MUrlUtil;

/**
 * 来源:百度接口
 * 单一
 */
public class AvSplashFragment extends MFragment implements HttpCallback<JSONObject> {
    private static final String TAG = AvSplashFragment.class.getSimpleName();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return super.onCreateView(inflater,container,savedInstanceState);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        loadData();
    }
    private void loadData() {
        String url = MUrlUtil.getUrl(R.string.av_path);
//        HttpClientProxy.getInstance().getAsyn(url, 1, null, this);

        try {
            Document document = Jsoup.connect(url).get();
            Elements elements = document.select(".c_red");
            if (elements == null || elements.size() == 0) {
                return;
            }
            String href = elements.get(0).attr("href");
            if(href!=null && href.contains("index")){
                Document subDoc = Jsoup.connect(url).get();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void onSucceed(int requestId, JSONObject result) {
        L.d(TAG, " onSucceed : " + result);

    }

    @Override
    public void onFail(int requestId, String errorMsg) {
        L.e(TAG, " onFail : " + errorMsg);
    }


}
